import {
    delete_device, delete_device_group, delete_device_group_relation,
    delete_device_maintenance_project,
    delete_device_maintenance_type,
    delete_device_maintenance_type_project_relation,
    delete_device_parts_relation, delete_spare_parts, delete_spare_parts_inventory, delete_spare_parts_request,
    get_cache_by_vaguename,
    get_device_grade_list, get_device_group_list, get_device_group_relation_list,
    get_device_inspection_all_list,
    get_device_inspection_project_list, get_device_inspection_project_relation_list,
    get_device_inspection_project_result_list,
    get_device_list,
    get_device_maintenance_info_all,
    get_device_maintenance_project_list,
    get_device_maintenance_type_list,
    get_device_maintenance_type_project_relation_list,
    get_device_manage_info_list,
    get_device_parts_relation_list,
    get_device_reform_info_list,
    get_device_repair_all_list,
    get_device_type_list, get_group_grade_list, get_spare_parts_inventory_list,
    get_spare_parts_list, get_spare_parts_request_list,
    get_supplier_by_id,
    get_userName_by_userId,
    save_device, save_device_group, save_device_group_relation,
    save_device_inspection_project, save_device_inspection_project_relation,
    save_device_maintenance_project,
    save_device_maintenance_type,
    save_device_maintenance_type_project_relation, save_device_manage_info,
    save_device_parts_relation, save_device_reform_info,
    save_spare_parts, save_spare_parts_request, save_spare_parts_request_parts_relation
} from "../services/deviceManagement";
import {
    delete_device_maintenance_info,
    delete_device_maintenance_plan,
    delete_device_maintenance_task,
    delete_maintenance_plan_device_relation,
    get_cache_by_id,
    get_cache_by_vaguename2,
    get_current_user_info,
    get_device_maintenance_plan_list,
    get_maintenance_plan_device_relation_list,
    get_warning_time_list,
    list_device_maintenance_info_all, list_device_maintenance_result,
    list_device_maintenance_task_all,
    list_device_maintenance_task_by_user_id,
    list_device_maintenance_type_project_relation,
    save_device_maintenance_info,
    save_device_maintenance_plan, save_device_maintenance_result,
    save_device_maintenance_task,
    save_maintenance_plan_device_relation
} from "../services/deviceMaintenance";
import {
    delete_device_repair,
    delete_device_repair_order,
    delete_device_repair_spare_parts_receive_relation,
    delete_spare_parts_receive,
    list_device_repair_all,
    list_device_repair_order_all,
    list_device_repair_order_by_user_id,
    list_device_repair_spare_parts_receive_relation,
    list_spare_parts,
    list_spare_parts_inventory,
    list_spare_parts_receive,
    save_device_repair,
    save_device_repair_order,
    save_device_repair_spare_parts_receive_relation,
    save_spare_parts_inventory,
    save_spare_parts_receive
} from "../services/deviceRepair";
import {
    delete_device_inspection,
    delete_device_inspection_plan,
    list_device_inspection_all,
    list_device_inspection_plan,
    list_device_inspection_plan_by_user_id,
    list_device_inspection_project,
    list_device_inspection_project_relation, save_device_inspection,
    save_device_inspection_plan, save_device_inspection_project_result
} from "../services/inspection";
import {
    delete_device_type,
    list_device_grade,
    list_device_maintenance_project,
    list_device_maintenance_type,
    list_device_type,
    list_fault_type,
    list_parts_type,
    save_device_grade,
    save_device_type, save_fault_type,
    save_parts_type,
    save_warning_time
} from "../services/basicInformation";
import {file_upload} from "../services/deviceManagement";

//接口实现
export function getDeviceManageInfoList(params){
    return new Promise(resolve => {
        get_device_manage_info_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//设备改造 通过device_id拿改造信息
export function getDeviceReformInfoList(params){
    return new Promise(resolve => {
        get_device_reform_info_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//点检关系表
export function getDeviceInspectionProjectResultList(params){
    return new Promise(resolve => {
        get_device_inspection_project_result_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//找点检项目
export function getDeviceInspectionProjectList(params){
    return new Promise(resolve => {
        get_device_inspection_project_list(params).then(({data: res}) => {
            if (res.code === '1000'){

                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//拿关系 list_device_maintenance_type_project_relation
export function getDeviceMaintenanceTypeProjectRelationList(params){
    return new Promise(resolve => {
        get_device_maintenance_type_project_relation_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//保养项目列表
export function getDeviceMaintenanceProjectList(params){
    return new Promise(resolve => {
        get_device_maintenance_project_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//拿维修记录
export function getDeviceRepairAllList(params){
    return new Promise(resolve => {
        get_device_repair_all_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//查点检记录
export function getDeviceInspectionAllList(params){
    return new Promise(resolve => {
        get_device_inspection_all_list(params).then(({data: res}) => {
            if (res.code === '1000'){
               resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//根据device_id获取关系relation
export function getRelationByDeviceId(params){
    return new Promise(resolve => {
        get_device_maintenance_info_all(params).then(({data: res}) => {
            if (res.code === '1000'){

                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//查询所有设备等级-基础
export function getAllDeviceGradeList(){
    let params = {}
    return new Promise(resolve => {
        get_device_grade_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)


            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//设备类型获取
export function getDeviceTypeList(){
    let params = {}
    return new Promise(resolve => {
        get_device_type_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//通过supplier_name查supplier_id supplierSearchList 查生产厂家
export function getSupplierIdByName(supplier_name){
    let params = {'cache_key':'supplier','name_value':supplier_name}
    return new Promise(resolve => {
        get_cache_by_vaguename(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//根据create_user查名字
export function getUserNameById(user_id){
    let params = {'cache_key':'user','id_value':user_id}
    return new Promise(resolve => {
        get_userName_by_userId(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data.name);
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//根据id获取供应商信息
export function getSupplierById(supplier_id){
    let params = {'cache_key':'supplier','id_value':supplier_id}
    return new Promise(resolve => {
        get_supplier_by_id(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//通过part_id查相关数据
export function getPartsById(params){
    return new Promise(resolve => {
        get_spare_parts_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

// 获取设备相关备件列表+通过part_id查相关数据
export function getDevicePartsRelationList(params){
    return new Promise(resolve => {
        get_device_parts_relation_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

// 获取设备列表
export function getDeviceList(params){
    return new Promise(resolve => {
        get_device_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//保存新增设备 save_device
export function saveDevice(deviceData) {
    return new Promise(resolve => {
        save_device(deviceData).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}


//保养类别
export function getDeviceMaintenanceTypeList(params){
    return new Promise(resolve => {
        get_device_maintenance_type_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//保存device_part关系
export function saveDevicePartsRelation(params){
    return new Promise(resolve => {
        save_device_parts_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//加part
export function saveSpareParts(params){
    return new Promise(resolve => {
        save_spare_parts(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//save保养类别
export function saveDeviceMaintenanceProject(params){
    return new Promise(resolve => {
        save_device_maintenance_project(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
export function saveDeviceMaintenanceType(params){
    return new Promise(resolve => {
        save_device_maintenance_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

export function saveDeviceMaintenanceTypeProjectRelation(params){
    return new Promise(resolve => {
        save_device_maintenance_type_project_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

export function saveDeviceInspectionProject(params){
    return new Promise(resolve => {
        save_device_inspection_project(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//删保养项目 delete_device_maintenance_project
export function deleteDeviceMaintenanceProject(params){
    return new Promise(resolve => {
        delete_device_maintenance_project(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//删保养类型 delete_device_maintenance_type
export function deleteDeviceMaintenanceType(params){
    return new Promise(resolve => {
        delete_device_maintenance_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

export function deleteDeviceMaintenanceTypeProjectRelation(params){
    return new Promise(resolve => {
        delete_device_maintenance_type_project_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//delete_device_parts_relation

export function deleteDevice(params){
    return new Promise(resolve => {
        delete_device(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

export function saveDeviceInspectionProjectRelation(params){
    return new Promise(resolve => {
        save_device_inspection_project_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

// get_device_inspection_project_relation_list

export function getDeviceInspectionProjectRelationList(params){
    return new Promise(resolve => {
        get_device_inspection_project_relation_list(params).then(({data: res}) => {
            if (res.code === '1000'){

                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//save_device_reform_info
export function saveDeviceReformInfo(params){
    return new Promise(resolve => {
        save_device_reform_info(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_device_manage_info status must
export function saveDeviceManageInfo(params){
    return new Promise(resolve => {
        save_device_manage_info(params).then(({data: res}) => {
            if (res.code === '1000'){
                console.log('OK');
                resolve(res)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//设备组 get_device_group_list
export function getDeviceGroupList(params){
    return new Promise(resolve => {
        get_device_group_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//get_group_grade_list
export function getGroupGradeList(params){
    return new Promise(resolve => {
        get_group_grade_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//get_device_group_relation_list

export function getDeviceGroupRelationList(params){
    return new Promise(resolve => {
        get_device_group_relation_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//delete_device_group_relation

export function deleteDeviceGroupRelation(params){
    return new Promise(resolve => {
        delete_device_group_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//save_device_group
export function saveDeviceGroup(params){
    return new Promise(resolve => {
        save_device_group(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_device_group_relation
export function saveDeviceGroupRelation(params){
    return new Promise(resolve => {
        save_device_group_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//delete_device_group
export function deleteDeviceGroup(params){
    return new Promise(resolve => {
        delete_device_group(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

// get_device_maintenance_plan_list
export function getDeviceMaintenancePlanList(params){
    return new Promise(resolve => {
        get_device_maintenance_plan_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//get_maintenance_plan_device_relation_list
export function getMaintenancePlanDeviceRelationList(params){
    return new Promise(resolve => {
        get_maintenance_plan_device_relation_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}


export function getWarningTimeList(params){
    return new Promise(resolve => {
        get_warning_time_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

export function saveDeviceMaintenancePlan(params){
    return new Promise(resolve => {
        save_device_maintenance_plan(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}


export function saveMaintenancePlanDeviceRelation(params){
    return new Promise(resolve => {
        save_maintenance_plan_device_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

export function deleteMaintenancePlanDeviceRelation(params){
    return new Promise(resolve => {
        delete_maintenance_plan_device_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//delete_device_maintenance_plan
export function deleteDeviceMaintenancePlan(params){
    return new Promise(resolve => {
        delete_device_maintenance_plan(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_maintenance_task_all

export function listDeviceMaintenanceTaskAll(params){
    return new Promise(resolve => {
        list_device_maintenance_task_all(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//当前用户
export function getCurrentUserInfo(params){
    return new Promise(resolve => {
        get_current_user_info(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//
export function getCacheByVaguename(user_name){
    const params = {'cache_key':'user','name_value':user_name}
    return new Promise(resolve => {
        get_cache_by_vaguename2(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}
//save_device_maintenance_task

export function saveDeviceMaintenanceTask(params){
    return new Promise(resolve => {
        save_device_maintenance_task(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}


export function deleteDeviceMaintenanceTask(params){
    return new Promise(resolve => {
        delete_device_maintenance_task(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//list_device_maintenance_info_all
export function listDeviceMaintenanceInfoAll(params){
    return new Promise(resolve => {
        list_device_maintenance_info_all(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//list_device_maintenance_task_by_user_id user_id
export function listDeviceMaintenanceTaskByUserId(params){
    return new Promise(resolve => {
        list_device_maintenance_task_by_user_id(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}
//找unit get_cache_by_id
export function getCacheById(unit_id){
    const params = {'cache_key':'unit','id_value':unit_id}
    return new Promise(resolve => {
        get_cache_by_id(params).then(({data: res}) => {
            if (res.code === '1000'){
                // console.log(res.data)
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//save_device_maintenance_info
export function saveDeviceMaintenanceInfo(params){
    return new Promise(resolve => {
        save_device_maintenance_info(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_device_maintenance_result
export function saveDeviceMaintenanceResult(params){
    return new Promise(resolve => {
        save_device_maintenance_result(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_maintenance_result
export function listDeviceMaintenanceResult(params){
    return new Promise(resolve => {
        list_device_maintenance_result(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

export function deleteDeviceMaintenanceInfo(params){
    return new Promise(resolve => {
        delete_device_maintenance_info(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//设备维修 list_device_repair_all
export function listDeviceRepairAll(params){
    return new Promise(resolve => {
        list_device_repair_all(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}
//list_device_repair_order_all
export function listDeviceRepairOrderAll(params){
    return new Promise(resolve => {
        list_device_repair_order_all(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//delete_device_repair_order
export function deleteDeviceRepairOrder(params){
    return new Promise(resolve => {
        delete_device_repair_order(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

export function saveDeviceRepairOrder(params){
    return new Promise(resolve => {
        save_device_repair_order(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_repair_order_by_user_id
export function listDeviceRepairOrderByUserId(params){
    return new Promise(resolve => {
        list_device_repair_order_by_user_id(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//list_spare_parts

export function listSpareParts(params){
    return new Promise(resolve => {
        list_spare_parts(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//save_device_repair
export function saveDeviceRepair(params){
    return new Promise(resolve => {
        save_device_repair(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_device_repair_spare_parts_receive_relation
export function saveDeviceRepairSparePartsReceiveRelation(params){
    return new Promise(resolve => {
        save_device_repair_spare_parts_receive_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_spare_parts_receive
export function listSparePartsReceive(params){
    return new Promise(resolve => {
        list_spare_parts_receive(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}

//save_spare_parts_receive
export function saveSparePartsReceive(params){
    return new Promise(resolve => {
        save_spare_parts_receive(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_spare_parts_inventory
export function listSparePartsInventory(params){
    return new Promise(resolve => {
        list_spare_parts_inventory(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}
//delete_device_repair
export function deleteDeviceRepair(params){
    return new Promise(resolve => {
        delete_device_repair(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_repair_spare_parts_receive_relation
export function listDeviceRepairSparePartsReceiveRelation(params){
    return new Promise(resolve => {
        list_device_repair_spare_parts_receive_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}
//delete_device_repair_spare_parts_receive_relation
export function deleteDeviceRepairSparePartsReceiveRelation(params){
    return new Promise(resolve => {
        delete_device_repair_spare_parts_receive_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//delete_spare_parts_receive
export function deleteSparePartsReceive(params){
    return new Promise(resolve => {
        delete_spare_parts_receive(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_inspection_plan
export function listDeviceInspectionPlan(params){
    return new Promise(resolve => {
        list_device_inspection_plan(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })

}
//delete_device_inspection_plan
export function deleteDeviceInspectionPlan(params){
    return new Promise(resolve => {
        delete_device_inspection_plan(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_device_inspection_plan
export function saveDeviceInspectionPlan(params){
    return new Promise(resolve => {
        save_device_inspection_plan(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_inspection_all
export function listDeviceInspectionAll(params){
    return new Promise(resolve => {
        list_device_inspection_all(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//delete_device_inspection
export function deleteDeviceInspection(params){
    return new Promise(resolve => {
        delete_device_inspection(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_inspection_plan_by_user_id
export function listDeviceInspectionPlanByUserId(params){
    return new Promise(resolve => {
        list_device_inspection_plan_by_user_id(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//list_device_inspection_project_relation
export function listDeviceInspectionProjectRelation(params){
    return new Promise(resolve => {
        list_device_inspection_project_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//list_device_inspection_project
export function listDeviceInspectionProject(params){
    return new Promise(resolve => {
        list_device_inspection_project(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
export function saveDeviceInspection(params){
    return new Promise(resolve => {
        save_device_inspection(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_device_inspection_project_result
export function saveDeviceInspectionProjectResult(params){
    return new Promise(resolve => {
        save_device_inspection_project_result(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_type
export function listDeviceType(params){
    return new Promise(resolve => {
        list_device_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
export function listDeviceGrade(params){
    return new Promise(resolve => {
        list_device_grade(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

export function listDeviceMaintenanceType(params){
    return new Promise(resolve => {
        list_device_maintenance_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_device_maintenance_project
export function listDeviceMaintenanceProject(params){
    return new Promise(resolve => {
        list_device_maintenance_project(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}

//http://localhost:7055/api/public/cache/get_cache_by_vaguename?cache_key=unit&name_value=千
export function getUnitIdByName(unit_name){
    let params = {'cache_key':'unit','name_value':unit_name}
    return new Promise(resolve => {
        get_cache_by_vaguename(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//部门
export function getOrganizationList(unit_name){
    let params = {'cache_key':'organization'}
    return new Promise(resolve => {
        get_cache_by_vaguename(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)

            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//get_spare_parts_inventory_list
export function getSparePartsInventoryList(params){
    return new Promise(resolve => {
        get_spare_parts_inventory_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//delete_spare_parts
export function deleteSpareParts(params){
    return new Promise(resolve => {
        delete_spare_parts(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//delete_device_parts_relation
export function deleteDevicePartsRelation(params){
    return new Promise(resolve => {
        delete_device_parts_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//get_spare_parts_request_list
export function getSparePartsRequestList(params){
    return new Promise(resolve => {
        get_spare_parts_request_list(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_spare_parts_request
export function saveSparePartsRequest(params){
    return new Promise(resolve => {
        save_spare_parts_request(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_spare_parts_request_parts_relation
export function saveSparePartsRequestPartsRelation(params){
    return new Promise(resolve => {
        save_spare_parts_request_parts_relation(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//delete_spare_parts_request
export function deleteSparePartsRequest(params){
    return new Promise(resolve => {
        delete_spare_parts_request(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
///spare_parts/listSparePartsReceive
///device_repair/listDeviceRepairSpareParts_receive_relation
//delete_spare_parts_inventory
export function deleteSparePartsInventory(params){
    return new Promise(resolve => {
        delete_spare_parts_inventory(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_warning_time/
export function saveWarningTime(params){
    console.log(params)
    return new Promise(resolve => {
        save_warning_time(params).then(({data: res}) => {
            console.log(res)
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_device_type
export function saveDeviceType(params){
    return new Promise(resolve => {
        save_device_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
export function saveDeviceGrade(params){
    return new Promise(resolve => {
        save_device_grade(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//delete_device_type
export function deleteDeviceType(params){
    return new Promise(resolve => {
        delete_device_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_parts_type
export function listPartsType(params){
    return new Promise(resolve => {
        list_parts_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_parts_type
export function savePartsType(params){
    return new Promise(resolve => {
        save_parts_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//list_fault_type
export function listFaultType(params){
    return new Promise(resolve => {
        list_fault_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve(res.data)
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_fault_type
export function saveFaultType(params){
    return new Promise(resolve => {
        save_fault_type(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
//save_spare_parts_inventory
export function saveSparePartsInventory(params){
    return new Promise(resolve => {
        save_spare_parts_inventory(params).then(({data: res}) => {
            if (res.code === '1000'){
                resolve("OK")
            } else if (res.code === '1002') {
                console.log(res.msg);
                console.log('NoData');
                resolve([])
            }
            resolve()
        })
            .catch(err => {
                console.log(err)
                console.log('Error');
                resolve([])
            })
    })
}
